<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="../css/bootstrap.min.css"/>
    <script type="text/javascript" src="../js/jquery-1.12.4.js"></script>
    <script type="text/javascript" src="../js/bootstrap.min.js"></script>
    <script type="text/javascript" src="../js/jquery.bootstrap.min.js"></script>
    <script type="text/javascript" src="../js/plugins/jquery.form.js"></script>
    <script type="text/javascript" src="../js/plugins/jquery.twbsPagination.min.js"></script>
    <script type="text/javascript">
        function toPage(page) {
            $("#myfrom").attr("action", "userFileselect?currPage=" + page);
            $("#myfrom").submit();
        }


        $(function () {

            //拿到当前页
            var currPage = ${pager.currPage};
            //拿到最后一页
            var totalPages = ${pager.totalPages};

            if (currPage <= 1) {
                $("#prev").removeAttr("href");
            }

            if (currPage >= totalPages) {
                $("#next").removeAttr("href");
            }

            $(".btn_audit").click(function(){
                var form=$("#editform");
                form.find("[name=state]").val($(this).val());
                $("#myModal").modal("hide");

                form.ajaxSubmit(function(data){

                    if(data.success){
                        $.messager.confirm("提示",data.msg,function(){
                            window.location.reload(true);
                        });
                    }else{
                        $.messager.confirm("提示","系统故障，操作失败");
                    }
                });
                return false;
            });

            $(".auditClass").click(function () {
                var json = $(this).data('json');
                $("#userFileId").val(json.userFileId);
                $("#applierName").html(json.applier);
                $("#fileType").html(json.fileType);
                $("#score").val(json.score);
                $("#image").attr("src", json.image);
                $('#myModal').modal("show");
            })

        });

        function aa() {
            $("[name='state']").val("-2");
            $("[name='time1']").val("");
            $("[name='time2']").val("");
        }


    </script>

</head>

<body>
<div style="width: 200px; float: left;margin-left: 150px;margin-top: 100px"    >
    <li class="list-group-item" >
        <a href="#" data-toggle="collapse" data-target="#auditmanage_detail">
            <span>审核项目</span>
        </a>
        <ul class="in" id="auditmanage_detail">
            <li class="realAuth">
                <a href="./realAuthselect">实名认证审核</a>
            </li>
            <li class="vedioAuth">
                <a href="./vedioAuthselect">视频认证审核</a>
            </li>
            <li class="userFileAuth">
                <a href="./userFileselect">认证材料审核</a>
            </li>
            <li class="bidrequest_publishaudit_list">
                <a href="./bidRequestSelect">发标前审核</a>
            </li>
            <li class="bidrequest_audit1_list">
                <a href="./bidRequestSelect1">满标一审</a>
            </li>
            <li class="bidrequest_audit2_list">
                <a href="./bidRequestSelect2">满标二审</a>
            </li>
        </ul>
    </li>
</div>
<div style="width: 1000px; float: left;margin-top: 50px;margin-left: 50px">
<center>
    <h1>风控资料审核</h1>
</center>
<form id="myfrom" action="./userFileselect" method="post">

    <center>
        状态
        <select name="state">
            <option value="-2">全部</option>
            <option value="0">申请状态</option>
            <option value="1">审核成功</option>
            <option value="-1">审核拒绝</option>
        </select>

        申请时间<input type="text" name="time1" value="${time1}"/>
        到&nbsp;<input type="text" name="time2" value="${time2}"/>
        <input type="submit" value="查询"/>

        <input type="button" onclick="aa()" value="重置"/>
        <Br/>
    </center>
    <table align="center" width="70%" border="1px" class="table">
        <tr align="center">
            <td>用户名</td>
            <td>状态</td>
            <td>分数</td>
            <td>资料类型</td>
            <td>审核人</td>
        </tr>
        <c:forEach items="${list}" var="user" varStatus="st">
            <tr align="center"
                    <c:if test="${st.index %2 ==0 }">
                        style="background-color:gray"
                    </c:if>
            >
                <input type="hidden" name="userFileId" value="${user.userFileId}">
                <td>${user.applier.userName }</td>
                <td>
                    <c:if test="${user.state== 0 }">申请状态</c:if>
                    <c:if test="${user.state== 1 }">审核通过</c:if>
                    <c:if test="${user.state==-1 }">审核拒绝</c:if>
                </td>
                <td>${user.score}</td>
                <td>${user.fileType.title }</td>
                <td>${user.auditor.userName }</td>
                <td>
                    <c:if test="${ empty user.auditor.userName}">
                        <a class="auditClass"
                           data-json='{"applier":"${user.applier.userName}"
                                ,"fileType":"${user.fileType.title}"
                                ,"image":"${user.image}","score":"${user.score}"
                                ,"userFileId":"${user.userFileId}" }'>
                            <button id="btn_add" type="button" class="btn btn-primary">审核</button>
                        </a>
                    </c:if>
                </td>
            </tr>
        </c:forEach>
    </table>

    <center>
        <a href="javaScript:toPage(1)">首页</a>&nbsp;&nbsp;
        <a id="prev" href="javaScript:toPage(${pager.currPage-1 })">上一页</a>&nbsp;&nbsp;
        <a id="next" href="javaScript:toPage(${pager.currPage+1 })">下一页</a>&nbsp;&nbsp;
        <a href="javaScript:toPage(${pager.totalPages})">尾页</a>&nbsp;&nbsp;
        <span>第${pager.currPage }页/共${pager.totalPages }页</span>
    </center>
</form>
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="modal-body">
                    <form class="form-horizontal" id="editform" method="post" action="./userFileUpdate">
                        <fieldset>
                            <div id="legend" class="">
                                <legend>风控材料认证审核</legend>
                            </div>
                            <input type="hidden" name="userFileId" id="userFileId" value="">
                            <input type="hidden" name="state" id="state" value="">
                            <div class="row">
                                <label class="col-sm-3 control-label" >用户名</label>
                                <div class="col-sm-6">
                                    <label class="form-control" name="applierName" id="applierName"></label>
                                </div>
                            </div>
                            <div class="row">
                                <label class="col-sm-3 control-label" >资料类型</label>
                                <div class="col-sm-6">
                                    <label class="form-control" name="fileType" id="fileType"></label>
                                </div>
                            </div>
                            <div class="row">
                                <label class="col-sm-3 control-label" >资料图片</label>
                                <div class="col-sm-6">
                                    <img src="" id="image1" style="width: 100px;">
                                </div>
                            </div>
                            <div class="row">
                                <label class="col-sm-3 control-label" >征信分数</label>
                                <div class="col-sm-6">
                                    <select name="score" id="score">
                                        <option value="1">1分</option>
                                        <option value="2">2分</option>
                                        <option value="3">3分</option>
                                        <option value="4">4分</option>
                                        <option value="5">5分</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label" >审核备注</label>
                                <div class="col-sm-6">
                                    <textarea name="remark" rows="7" cols="60"></textarea>
                                </div>
                            </div>
                        </fieldset>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-success btn_audit" value="1">审核通过</button>
                    <button type="button" class="btn btn-warning btn_audit" value="-1">审核拒绝</button>
                </div>

            </div>
        </div>
    </div>
</div>
</body>
</html>
